package com.neuedu.yyzx.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.neuedu.yyzx.mapper.BooksMapper;
import com.neuedu.yyzx.po.Books;
import com.neuedu.yyzx.service.BooksService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.math.BigDecimal;
import java.util.List;
@Service
public class BooksServiceImpl implements BooksService {
	@Autowired
	private BooksMapper booksMapper;
	public List<Books> selectBooksByName(String title){
		return booksMapper.selectBooksByName(title);
	}
	public int updateByName(String title,BigDecimal price,int stock) {
		QueryWrapper qw = new QueryWrapper();
    	qw.eq("title", title);
		Books book = new Books();
		book.setPrice(price);
		book.setStock(stock);
		return this.booksMapper.update(book, qw);
	}
	public IPage<Books> getPage(int curr) {
		IPage<Books> page = new Page<Books>(curr,3);
		return booksMapper.selectPage(page, null);
	}
}
